Socket
Socket
Sign inDemoInstall

@smithy/middleware-content-length

Package Overview
Dependencies
3
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/middleware-content-length


Version published
Weekly downloads
11M
decreased by-16.76%
Maintainers
0
Created
Weekly downloads
 

Package description

What is @smithy/middleware-content-length?

@smithy/middleware-content-length is a middleware package for the Smithy client framework. It is used to automatically calculate and set the Content-Length header for HTTP requests. This is particularly useful when dealing with payloads where the size needs to be explicitly defined.

What are @smithy/middleware-content-length's main functionalities?

Automatic Content-Length Calculation

This feature automatically calculates the Content-Length of the request body and sets it in the HTTP headers. This is useful for ensuring that the server knows the size of the incoming request payload.

const { ContentLengthMiddleware } = require('@smithy/middleware-content-length');
const { HttpRequest } = require('@smithy/protocol-http');

const request = new HttpRequest({
  hostname: 'example.com',
  method: 'POST',
  body: JSON.stringify({ key: 'value' })
});

const middleware = ContentLengthMiddleware();
const handler = middleware((next) => async (args) => {
  return next(args);
});

handler({ request }).then((response) => {
  console.log(response.request.headers['Content-Length']); // Outputs the calculated Content-Length
});

Other packages similar to @smithy/middleware-content-length

Readme

Source

@smithy/middleware-content-length

NPM version NPM downloads

FAQs

Last updated on 27 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc